<template>
  <div class="box">
    <header class="header">
      <van-nav-bar
        title="添加品牌标签"
        right-text="取消"
        :border="false"
        @click-right="$router.go(-1)"
      />
      <van-search v-model="brandTag" shape="round" placeholder="输入你想标记的品牌" />
      <ul class="brand-tag-list">
        <li v-for="(item, index) of tags" :key="index">
          <i></i>
          <span @click="goPreview(item)">{{ item.txt }}</span>
        </li>
      </ul>
    </header>
  </div>
</template>

<script>
import Vue from 'vue'
import { NavBar, Search } from 'vant'
import Bus from '@/utils/bus.js'

Vue.use(NavBar)
Vue.use(Search)

export default {
  data () {
    return {
      brandTag: '',
      tags: [{ txt: 'Dior' }, { txt: 'Dior2' }]
    }
  },
  methods: {
    goPreview (item) {
      Bus.$emit('brandTag', item.txt)
      this.$router.go(-1)
    }
  },
  beforeRouteLeave (to, from, next) {
    if (to.name === 'preview') {
      to.meta.keepAlive = true
    }
    next()
  }
}
</script>

<style lang="scss" scoped>
@import '@/assets/css/community/addBrandTag.scss';
</style>
